import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-03-13
 * Time: 18:40
 */
class MinStack {
    private Stack<Integer> stack;
    private Stack<Integer> minStack;
    public MinStack() {
        stack = new Stack<>();
        minStack = new Stack<>();
    }

    public void push(int val) {
        stack.push(val);
        if (!minStack.empty()) {
            int top = minStack.peek();
            //比较 小于等于的话 也要放进来
            if (val <= top) {
                minStack.push(val);
            }
        } else {
            minStack.push(val);
        }
    }

    public void pop() {
        int popVal = stack.pop();
        if (!minStack.empty()) {
            int top = minStack.peek();
            if (top == popVal) {
                minStack.pop();
            }
        }
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }
}

class Solution {
    public boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == '(' || ch == '[' || ch == '{') {
                //如果是左括号直接入栈
                stack.push(ch);
            } else {
                //如果是右括号
                if (stack.empty()) {
                    //右括号多
                    System.out.println("右括号多！");
                    return false;
                }
                char top = stack.peek();
                if (top == '(' && ch == ')' || top == '[' && ch == ']' || top == '{' && ch == '}') {
                    //如果左括号和右括号匹配 则弹出这个左括号
                    stack.pop();
                } else {
                    //左右括号不匹配
                    System.out.println("左右括号不匹配！");
                    return false;
                }
            }
        }
        if (!stack.empty()) {
            //左括号多
            System.out.println("左括号多！");
            return false;
        }
        return true;
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Queue<Integer> queue = new LinkedList<>();
        queue.add(1);
        queue.add(6);
        queue.offer(2);
        System.out.println(queue.peek());//1
        System.out.println(queue.element());//1
        System.out.println(queue.poll());//1
        System.out.println(queue.poll());//6
        System.out.println(queue.remove());//2
    }
    public static void main1(String[] args) {
        Queue<Integer> queue = new LinkedList<>();
        Deque<Integer> deque = new LinkedList<>();
        LinkedList<Integer> list = new LinkedList<>();

    }
}
